package cn.cyh.queue_service.exception;

import cn.cyh.queue_service.common.ResultCode;
import lombok.Getter;

/**
 * 业务异常类
 */
@Getter
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private final ResultCode resultCode;

    /**
     * 创建业务异常（使用默认错误码）
     */
    public BusinessException(String message) {
        super(message);
        this.resultCode = ResultCode.FAILED;
    }

    /**
     * 创建业务异常（指定错误码）
     */
    public BusinessException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }

    /**
     * 创建业务异常（指定错误码和消息）
     */
    public BusinessException(ResultCode resultCode, String message) {
        super(message);
        this.resultCode = resultCode;
    }

    /**
     * 创建业务异常（带原因）
     */
    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.resultCode = ResultCode.FAILED;
    }

    /**
     * 创建业务异常（指定错误码，带原因）
     */
    public BusinessException(ResultCode resultCode, Throwable cause) {
        super(resultCode.getMessage(), cause);
        this.resultCode = resultCode;
    }

    /**
     * 创建业务异常（指定错误码和消息，带原因）
     */
    public BusinessException(ResultCode resultCode, String message, Throwable cause) {
        super(message, cause);
        this.resultCode = resultCode;
    }
} 